<?php

/**
 * memberzoneComments actions.
 *
 * @package    jobeet
 * @subpackage memberzoneComments
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class memberzoneAccountDataActions extends myFrontendAction
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex(sfWebRequest $request)
  {
    $this->forward('default', 'module');
  }

  public function executeSubmit(sfWebRequest $request){

	  $status = '';
	  $shortMessage = '';
	  $messages = array();

	$this->form = new AccountDataForm($this->getUser()->getObject());
	$this->form->bind($request->getParameter($this->form->getName()));

	if($this->form->isValid()){

		$this->form->save();

		$status = 200;
		$shortMessage = 'Success';

	}else{
			$shortMessage = 'Epic fail';
			$status = 500;
			foreach($this->form->getErrorSchema() as $index => $err){
				$messages[$index] = $err . " ";
			}
	}

	return $this->renderPartial('global/json', array(
		'item' => array(
			'messages' => $messages,
			'status' => $status,
			'shortMessage' => $shortMessage
		)
	));

  }
}
